package test_achieve.h5_2;

import constant.Constant;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.api.java.zh_cn.那么;
import org.junit.Assert;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions;
import test_achieve.Hooks;
import test_achieve.h5_2.Login;
import util.tools.BusinessTools;
import util.tools.CommonTools;

/**
 * Created by chenkuo on 2017/7/19.
 */
public class HclientBuniness {
    Login login = new Login();
    OrderMain orderMain = new OrderMain();

    @Given("^H用户已登录：(.+)：(.+)$")
    public void H用户已登录(String name, String pw) throws Throwable {
        login.H进入用户登录界面();
        login.H选择密码登录();
        login.H输入用户账户密码(name, pw);
        login.H点击登录按钮();
         login.H输入图形验证码();
         orderMain.H点击我知道了();
        orderMain.H点击个人中心图标();
         orderMain.H点击我的钱包();
        orderMain.H获取闪送余额();
        //回到下单页面
        CommonTools.back(Constant.driverH, 1);
    }
    @Given("^H用户登录：(.+)：(.+)$")
    public void H用户登录(String name, String pw) throws Throwable {
        login.H进入用户登录界面();
        login.H选择密码登录();
        login.H输入用户账户密码(name, pw);
        login.H点击登录按钮();
        login.H输入图形验证码();
    }
    @Given("^H取消订单验证账户余额:(\\d+)$")
    public void H取消订单验证账户余额(int p) throws Throwable {
        orderMain.H回到首页();
        orderMain.H点击个人中心图标();
        orderMain.H点击我的订单();
        orderMain.H进入订单详情();
        orderMain.H取消订单();
        orderMain.H回到首页();
        orderMain.H点击个人中心图标();
        orderMain.H点击我的钱包();
        orderMain.H账户余额正确(p);
    }



    @Then("^H订单信息正确$")
    public void H订单信息正确() throws Throwable {
        //在订单列表页刷新页面后，订单状态变为 闪送完成
        Constant.driverH.navigate().refresh();//刷新当前页面
        Assert.assertTrue(Constant.driverH.findElement(
                By.xpath("//*[@id=\"body\"]/div/ul/li[1]/div/div[1]/div[1]/span[2]")).getText().equals("闪送完成"));
        //进入订单详情 订单状态变为 闪送完成
        Constant.driverH.findElement(By.xpath("//*[@id=\"body\"]/div/ul/li[1]/div/div[1]/div[1]/span[1]")).click();
        Assert.assertTrue(Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[1]/div/span[2]")).getText().equals("闪送完成"));
        //进入订单进度页面 显示 恭喜您的物品已送达!
        Constant.driverH.findElement(By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[1]/a[1]/span")).click();
        Assert.assertTrue(Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[2]/div[1]/div/span[1]")).getText().equals("恭喜您的物品已送达!"));

    }

    @And("^H设置加小费金额:(\\d+)$")
    public void H设置加小费金额(int addPrice) throws Throwable {
        //-----点击【我要加小费】
        Thread.sleep(1000);
        WebElement element = Constant.driverH.findElement(By.xpath("//*[text()=\"我要加小费\"]"));
        CommonTools.scrollToElement(Constant.driverH, element);
        element.click();
        //-----处理加消费的逻辑
        Actions action = new Actions(Constant.driverH);
        Thread.sleep(1000);
        //进来后，默认的0 顶层位置
        WebElement s = Constant.driverH.findElement(By.cssSelector("div.zby-picker-column-indicator"));
        //要加价的钱数

        int n = addPrice / 5 + 1;
        for (int i = 0; i < n; ) {
            WebElement e = Constant.driverH.findElement
                    (By.xpath("//*[@id=\"company-app\"]/div/div/div/div[1]/div[4]/div/div[3]/div[1]/div[2]/div[2]/div/div/div/div[3]/div[" + n + "]"));
            action.clickAndHold(s).moveToElement(e).perform();
            action.click(s).perform();
            action.click(s).perform();
            Thread.sleep(2000);
            i = i + 2;
        }
        Constant.driverH.findElement(By.xpath("//*[text()=\"确定\"]")).click();

    }

    @And("^H设置订单基本信息：(.+)：(.+)：(.+)$")
    public void H设置订单基本信息(String fAdr, String tAdr, String tel) throws Throwable {
        orderMain.H设置发件地址信息(fAdr);
        orderMain.H设置收寄件人信息(tel);
        orderMain.H点击确定();
        orderMain.H点击送到哪里();
        orderMain.H设置收件地址信息(tAdr);
        orderMain.H设置收寄件人信息(tel);
        orderMain.H点击确定();
    }

    @And("^H设置城市和订单基本信息：(.+)：(.+)：(.+)：(.+)$")
    public void H设置城市和订单基本信息(String city, String fAdr, String tAdr, String tel) throws Throwable {
        orderMain.H点击选择城市图标();
        orderMain.H选择城市(city);
        orderMain.H点击发件信息();
        orderMain.H设置发件地址信息(fAdr);
        orderMain.H设置收寄件人信息(tel);
        orderMain.H点击确定();
        orderMain.H点击送到哪里();
        orderMain.H设置收件地址信息(tAdr);
        orderMain.H设置收寄件人信息(tel);
        orderMain.H点击确定();
        Thread.sleep(1000);
        orderMain.H不使用优惠劵();
    }
    @And("^H设置城市和订单信息使用优惠劵：(.+)：(.+)：(.+)：(.+)$")
    public void H设置城市和订单信息使用优惠劵(String city, String fAdr, String tAdr, String tel) throws Throwable {
        orderMain.H点击选择城市图标();
        orderMain.H选择城市(city);
        orderMain.H点击发件信息();
        orderMain.H设置发件地址信息(fAdr);
        orderMain.H设置收寄件人信息(tel);
        orderMain.H点击确定();
        orderMain.H点击送到哪里();
        orderMain.H设置收件地址信息(tAdr);
        orderMain.H设置收寄件人信息(tel);
        orderMain.H点击确定();
    }

    @And("^H设置取件时间:(.+)：(\\d+)$")
    public void H设置取件时间(String date, int hour) throws Throwable {
        Thread.sleep(1000);
        WebElement element = Constant.driverH.findElement(By.xpath("//*[text()=\"取件时间\"]"));
        CommonTools.scrollToElement(Constant.driverH, element);
        element.click();

        if (!"立即取件".contains(hour + "")) {
            Actions action = new Actions(Constant.driverH);
            Thread.sleep(1000);
            //1 设置取件时间(今天or明天)
            int d = 2;
            if ("今天".equals(date)) {
                d = 1;
            }
            WebElement dateS = Constant.driverH.findElements(By.cssSelector("div.zby-picker-column-indicator")).get(0);
            WebElement dateE = Constant.driverH.findElement
                    (By.xpath("//*[@id=\"company-app\"]/div/div/div/div[1]/div[4]/div/div[1]/div/div[1]/div[2]/div[2]/div/div[1]/div/div[3]/div[" + d + "]"));
            action.clickAndHold(dateS).moveToElement(dateE).perform();
            action.click(dateS).perform();
            action.click(dateS).perform();
            Thread.sleep(2000);

            //2 设置取件时间(2)
            WebElement timeS = Constant.driverH.findElements(By.cssSelector("div.zby-picker-column-indicator")).get(1);
            hour = hour + 1;
            WebElement timeE = Constant.driverH.findElement
                    (By.xpath("//*[@id=\"company-app\"]/div/div/div/div[1]/div[4]/div/div[1]/div/div[1]/div[2]/div[2]/div/div[2]/div/div[3]/div[" + hour + "]"));
            action.clickAndHold(timeS).moveToElement(timeE).perform();
            action.click(timeS).perform();
            action.click(dateS).perform();
            Thread.sleep(2000);
        }
        //点击确定
        Constant.driverH.findElement(By.xpath("//*[text()=\"确定\"]")).click();
    }

    @Then("^H验证加价订单金额:(.+)：(.+)$")
    public void H验证加价订单金额(String price, String addPrice) throws Throwable {
        System.out.println(Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div/div[1]")).getText());
        int finalPrice = Integer.parseInt(price) + Integer.parseInt(addPrice);
        System.out.println("finalPrice = " + finalPrice);
        Assert.assertTrue(
                Constant.driverH.findElement(
                        By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div/div[1]")).getText().
                        contains(String.valueOf(finalPrice))
        );
    }

    @Then("^H取消订单后账户余额正确$")
    public void H取消订单后账户余额正确() throws Throwable {
        //从订单列表页 回退一次 到 个人中心页
        CommonTools.back(Constant.driverH, 1);
        Constant.driverH.navigate().refresh();//刷新页面
        Float count = Float.parseFloat(
                Constant.driverH.findElement(By.xpath("//*[@id=\"subcard-balance\"]/b")).getText()
        );
        System.out.println("取消单后账户余额：" + count);
        Assert.assertEquals(Constant.h5Account, count, 00000.1);

    }

    @And("^H获得订单信息$")
    public void H获得订单信息() throws Throwable {
        //取件信息
        String fInf = Constant.driverH.findElement(By.cssSelector("div.from-addr.addr-detail")).getText();
        fInf = fInf.replaceAll("\r|\n|,|\\s*", "");//去换行，逗号，空格
        //送件信息
        String tInf = Constant.driverH.findElement(By.cssSelector("div.to-addr.addr-detail")).getText();
        tInf = tInf.replaceAll("\r|\n|,|\\s*", "");

        //物品信息
        WebElement element = Constant.driverH.findElement(By.cssSelector("span.o-information"));
        CommonTools.scrollToElement(Constant.driverH, element);
        String s = element.getText();
        String[] ss = s.split("/");
        String type = ss[0];
        String weight = ss[1];
        //取件时间
//        String time = Constant.driverH.findElement(By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[3]/div[2]/div/div/span[2]")).getText();
//        //备注信息
//        String memo = Constant.driverH.findElement(By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[3]/div[3]/div/div[2]/span[2]")).getText();
//        //公斤
//        String weight = Constant.driverH.findElement(By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[2]/div/span[3]")).getText();
//        Constant.orderDetail.put("orderN", orderN);
        Constant.orderDetail.put("fInf", fInf);
        Constant.orderDetail.put("tInf", tInf);
        Constant.orderDetail.put("type", type);
//        Constant.orderDetail.put("time", time);
//        Constant.orderDetail.put("memo", memo);
        Constant.orderDetail.put("weight", weight);
        System.out.println(" 取件信息:"+fInf);
        System.out.println("rinf :" + tInf);
        System.out.println(" type:" + type);
//        System.out.println(" time:"+time);
//        System.out.println(" memo:"+memo);
        System.out.println(" weight:"+weight);
    }

    @And("^H验证下单信息$")
    public void H验证下单信息() throws Throwable {
        //取件信息
        String fInf = Constant.driverH.findElements(By.cssSelector("div.i-address-mess")).get(0).getText();
        fInf = fInf.replaceAll("\\s*|\t|\r|\n", "");
        //送件信息
        String tInf = Constant.driverH.findElements(By.cssSelector("div.i-address-mess")).get(1).getText();
        tInf = tInf.replaceAll("\\s*|\t|\r|\n", "");//去回车，换行，空格

        //物品类型
        String type = Constant.driverH.findElement(By.cssSelector("span.i-goodName")).getText();
//        //取件时间
//        String time = Constant.driverH.findElement(By.cssSelector("span.fetch-time-input")).getText();
//        //备注信息
////        String memo= Constant.driverH.findElement(By.xpath("//*[@id=\"iss-app\"]/div/div[1]/div[5]/div[1]/input")).getAttribute("value");
//        //公斤
        String weight = Constant.driverH.findElement(By.cssSelector("div.i-weight.f-blue")).getText();
        System.out.println(" ==fInf:"+fInf);
        System.out.println(" ==tInf:"+tInf);
        System.out.println(" ==type:"+type);
//        System.out.println(" ==time："+time);
//        System.out.println(" ==memo:"+memo);
        System.out.println("==weight:"+weight);
//        System.out.println("=========================");
//        System.out.println(Constant.orderDetail.get("fInf").toString().trim());
        Assert.assertTrue(Constant.orderDetail.get("fInf").toString().trim().equals(fInf));
        Assert.assertTrue(Constant.orderDetail.get("tInf").toString().trim().contains(tInf));
        Assert.assertTrue(Constant.orderDetail.get("type").equals(type));
//        Assert.assertTrue(Constant.orderDetail.get("time").equals(time));
////        Assert.assertTrue( Constant.orderDetail.get("memo").equals(memo));
        Assert.assertTrue(weight.contains(Constant.orderDetail.get("weight").toString()));

    }

    @And("^H设置物品重量:(\\d+)$")
    public void H设置物品重量(int weight) throws Throwable {
        Thread.sleep(1000);
        Constant.driverH.findElement(By.cssSelector("div[class='i-weight f-blue']")).click();
        Actions action = new Actions(Constant.driverH);
        Thread.sleep(1000);
        //进来后，默认的公斤<5 顶层位置
        WebElement s = Constant.driverH.findElement
                (By.xpath("//*[@id=\"company-app\"]/div/div/div/div[1]/div[3]/div[1]/div[2]/div[2]/div/div[2]/div/div[2]"));
        //要增加到的公斤数的 下一层级定位，例如，增加到6公斤，那么最后一个为div[2]，增加到7公斤，那么最后一个为div[3]，增加到8公斤，那么最后一个为div[4]
        if (weight > 5) {
            weight = weight;
        } else {
            weight = 5;
        }
        int kg = weight - 4;
        for (int i = 0; i < kg; ) {
            WebElement e = Constant.driverH.findElement
                    (By.xpath("//*[@id=\"company-app\"]/div/div/div/div[1]/div[3]/div[1]/div[2]/div[2]/div/div[2]/div/div[3]/div[" + kg + "]"));
            action.clickAndHold(s).moveToElement(e).perform();
            action.click(s).perform();
            action.click(s).perform();
            Thread.sleep(2000);
            i = i + 3;
        }
//选好公斤后点击确定按钮
        Constant.driverH.findElement(By.xpath("//*[@id=\"company-app\"]/div/div/div/div[1]/div[3]/div[1]/div[2]/div[1]/span[3]")).click();
    }



    @Then("^H验证订单金额:(.+)$")
    public void H验证订单金额(String price) throws Throwable {
//        Constant.driverH.navigate().refresh();
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
              By.cssSelector("div.i-price-s")).getText();
//        System.out.println("下单页订单价格：" + p);
        Assert.assertEquals("¥"+price,p);
    }
    @Then("^H详情页验证订单价格:(.+)$")
    public void H详情页验证订单价格(String price) throws Throwable {
        Thread.sleep(1000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"company-app\"]/div/div/div[3]/div[2]/div/div/div[2]/div[6]/span[2]")).getText();
        System.out.println("详情页订单价格：" + p);
        Assert.assertEquals(price+"元",p);
    }
    @Then("^H验证续重订单金额：(\\d+)：(\\d+)$")
    public void H验证续重订单金额(int price,int kmPrice) throws Throwable {
        int all=price+kmPrice;
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
                By.cssSelector("div.i-price-s")).getText();
//        System.out.println("下单页订单价格：" + p);
        Assert.assertEquals("¥"+all,p);
    }
    @Then("^H验证续重夜间费订单金额：(\\d+)：(\\d+)：(\\d+)$")
    public void H验证续重夜间费订单金额(int price,int kmPrice,int nightPrice) throws Throwable {
        int all=price+kmPrice+nightPrice;
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
                By.cssSelector("div.i-price-s")).getText();
//        System.out.println("下单页订单价格：" + p);
        Assert.assertEquals("¥"+all,p);
    }
    @Then("^H验证续重夜间费加小费订单金额：(\\d+)：(\\d+)：(\\d+)：(\\d+)$")
    public void H验证续重夜间费加小费订单金额(int price,int kmPrice,int nightPrice,int addPrice) throws Throwable {
        int all=price+kmPrice+nightPrice+addPrice;
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
                By.cssSelector("div.i-price-s")).getText();
//        System.out.println("下单页订单价格：" + p);
        Assert.assertEquals("¥"+all,p);
    }

    @Then("^H验证支付页订单金额:(.+)$")
    public void H验证支付页订单金额(String price) throws Throwable {
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[3]/div/div[1]")).getText();
        System.out.println("支付页订单价格：" + p);
        Assert.assertTrue(p.equals("￥" + price));
    }

    @Then("^H验证订单详情中总价:(.+)$")
    public void H验证订单详情中总价(String price) throws Throwable {
        Thread.sleep(1000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[2]/div/span[1]")).getText().trim();
        System.out.println("订单详情中总价：" + p);
        Assert.assertTrue(p.contains(price));
    }

    @Then("^H验证订单详情中订单总价:(.+)$")
    public void H验证订单详情中订单总价(String price) throws Throwable {
        Thread.sleep(1000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[3]/div[5]/div/div[1]/div[1]/span[2]")).getText().trim();
        System.out.println("订h验证订单详情中订单总价：" + p);
        Assert.assertTrue(p.contains(price));
    }

    @Then("^H验证订单详情中实付款:(.+)$")
    public void H验证订单详情中实付款(String price) throws Throwable {
        Thread.sleep(1000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[3]/div[5]/div/div[4]/span[2]")).getText().trim();
        System.out.println("h验证订单详情中实付款：" + p);
        Assert.assertTrue(p.contains(price));
    }

    @Then("^H验证账户余额$")
    public void H验证账户余额() throws Throwable {
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div/div[2]/div[2]")).getText();
        System.out.println("账户余额：" + p);
        String account = "" + (int) Constant.h5Account;
        System.out.println("账户余额：" + account);
        Assert.assertTrue(p.contains(account));
    }

    @Then("^H验证账户余额:(\\d+)$")
    public void H验证账户余额(int price) throws Throwable {
        Thread.sleep(2000);
        String p = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div/div[2]/div[2]")).getText();
        System.out.println("账户余额：" + p);
        String account = "" + ((int) Constant.h5Account - price);
        System.out.println("账户余额：" + account);
        Assert.assertTrue(p.contains(account));
    }


    @Then("^H取消订单成功$")
    public void H取消订单成功() throws Throwable {
        Thread.sleep(1000);
        Assert.assertTrue("已取消".equals(
                Constant.driverH.findElement(By.xpath("//*[@id=\"body\"]/div/ul/li[1]/div/div[1]/div[1]/span[2]")).getText())
        );
    }



    @Then("^H全部订单列表正确$")
    public void H全部订单列表正确() throws Throwable {
        String status1 = Constant.driverH.findElement(By.xpath("//*[@id=\"body\"]/div/ul/li[1]/div/div[1]/div[1]/span[2]")).getText();
        String status2 = Constant.driverH.findElement(By.xpath("//*[@id=\"body\"]/div/ul/li[2]/div/div[1]/div[1]/span[2]")).getText();
        Assert.assertTrue(status1.equals("待支付"));
        Assert.assertTrue(status2.equals("已取消"));
    }

    @Then("^H订单列表正确:(.+)$")
    public void H订单列表正确(String status) throws Throwable {
        Thread.sleep(1000);
        String s = Constant.driverH.findElement(
                By.xpath("//*[@id=\"body\"]/div/ul/li/div/div[1]/div[1]/span[2]")).getText();
//        System.out.println(" s:"+s);
//        System.out.println(" status:"+status);
        Assert.assertTrue(s.equals(status));
    }

    @Then("^H订单详情正确:(.+)$")
    public void H订单详情正确(String status) throws Throwable {
        String s[] = status.split(",");
        String status1 = Constant.driverH.findElement(
                By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[1]/div/span[2]")).getText();
        String button1 = "";
        String button2 = "";
        if (s[0].equals("待支付")) {
            button1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/a")).getText();
        } else if (s[0].equals("已取件")) {
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button")).getText();
        } else if (s[0].equals("闪送完成")) {
            button1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/a[1]")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/a[2]")).getText();
        } else {
            button1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button[2]")).getText();
        }
//        System.out.println("button1:"+button1);
//        System.out.println("===s[1]:"+s[1]);
        Assert.assertTrue(status1.equals(s[0]));
        Assert.assertTrue(button1.equals(s[1].trim()));
        Assert.assertTrue(button2.equals(s[2]));
    }

    @Then("^H订单进度正确:(.+)$")
    public void H订单进度正确(String status) throws Throwable {
        String s[] = status.split(",");

        String status1 = "";
        String button1 = "";
        String button2 = "";
        if (s[0].equals("取件成功")) {
            status1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[2]/div[1]/div/span[1]")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button")).getText();
        } else if (s[0].equals("等待支付")) {
            status1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div/div/div/span[1]")).getText();
            button1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/a")).getText();
        } else if (s[0].equals("恭喜您的物品已送达!")) {
            status1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[2]/div[1]/div/span[1]")).getText();
            button1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/a[1]")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/a[2]")).getText();
        } else if (s[0].equals("抢单成功")) {
            status1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[1]/div[2]/div[1]/div/span[1]")).getText();
            button1 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button[1]")).getText();
            button2 = Constant.driverH.findElement(
                    By.xpath("//*[@id=\"iss-app\"]/div/div[2]/div[2]/div[2]/div/div[2]/div/button[2]")).getText();
        }
//        System.out.println("status1:"+status1);
//        System.out.println("===s[0]:"+s[0]);
        Assert.assertTrue(status1.equals(s[0]));
        Assert.assertTrue(button1.equals(s[1].trim()));
        Assert.assertTrue(button2.equals(s[2]));
    }

    @And("^H设置物品类型：(.+)$")
    public void H设置物品类型(String type) throws Throwable {
        Thread.sleep(1000);
        Constant.driverH.findElement(By.cssSelector("span.i-goodName")).click();
        Actions action = new Actions(Constant.driverH);
        Thread.sleep(1000);
        //进来后，默认的 【文件】顶层位置
        WebElement s = Constant.driverH.findElement
                (By.cssSelector("div.zby-picker-column-indicator"));
        //要滑动到的位置
        WebElement e = Constant.driverH.findElement
                ( By.xpath("//*[text()=\""+type+"\"]"));

            action.clickAndHold(s).moveToElement(e).perform();
            action.click(s).perform();
            action.click(s).perform();
            Thread.sleep(2000);

//选好物品类型后点击确定按钮
        Constant.driverH.findElement(By.xpath("//*[text()=\"确定\"]")).click();
    }

}
